﻿use MyShop
go
create view v_RoleFunction
as
select distinct
srf.RoleId,
cast( case srf.ButtonId when null then 0 when '00000000-0000-0000-0000-000000000000' then 0 else 1 end as bit) as IsButton,
sm.Id as MenuId,
sm.ParentId,
sb.Id as ButtonId,
sm.MemuName,
sm.IndexNum,
sm.AreaStr,
sm.ControllerStr,
sm.ActionStr,
sm.Icons as MenuIcons,
smb.ButtonName,
smb.Icons as ButtonIcons,
smb.Titles,
sb.ButtonTag,
sb.ButtonNum
 from [dbo].[SystemRoleFunction] srf left join [dbo].[SystemMenu] sm on srf.MenuId=sm.Id
left join [dbo].[SystemMenuButton] smb on srf.ButtonId=smb.Id and sm.Id=smb.MenuId
left join [dbo].[SystemButton] sb on smb.ButtonId=sb.Id
where srf.IsDel=0  and sm.IsDel=0 and (sb.IsDel=0 or sb.IsDel is null)